package com.sun.spring5.testdemo;

import com.sun.spring5.User;
import com.sun.spring5.bean.Orders;
import com.sun.spring5.bean.Person;
import com.sun.spring5.config.MainConfig;
import com.sun.spring5.config.PersonSerivce;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Profile;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.Executors;

public class TestSpring5 {
    @Test
    public void testAdd(){
        //加载spring的配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");

        //获取配置创建的对象
        User user = context.getBean("user", User.class);
        System.out.println("testspring5:"+user.getClass());
        user.add();
    }



    @Test
    public void getPerson(){
        ApplicationContext ioc = new AnnotationConfigApplicationContext(MainConfig.class);
        Orders orders =  ioc.getBean("orders",Orders.class);
        orders.show();
        System.out.println(orders.getClass());


    }



    @Test
    public void getPerson2(){
        ApplicationContext ioc = new AnnotationConfigApplicationContext(MainConfig.class);
        Object bean =  ioc.getBean("personSerivceImpl");
        System.out.println(bean.getClass());
    }
}
